package woshiheima6;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class ConlectionDemo {
    public static void main(String[] args) {
//创建conlection集合对象
        Collection<Student> c = new ArrayList<Student>();
        //创建学生对象
        Student s1 = new Student();
        s1.setName("林青霞");
        s1.setAge(18);

        Student s2 = new Student();
        s2.setName("林青");
        s2.setAge(18);

        Student s3 = new Student();
        s3.setName("林");
        s3.setAge(18);
        //将对象传给Connectin集合
        c.add(s1);
        c.add(s2);
        c.add(s3);
        //使用迭代器遍历集合
        Iterator<Student> it=c.iterator();
        while (it.hasNext()){
            Student s=it.next();
            System.out.println(s.getName()+","+s.getAge());
        }

    }
}
